#ifndef _VISITOR_H_
#define _VISITOR_H_


/*
	class : Visitor
	desc : A class made to create an interface for using
	the visitor pattern. This is mainly to try to make life
	easier when dealing with problems that require an implementation
	of the vistor pattern before it works well enough for use.
*/
template<typedef Data>
class Visitor
{
	public : 
	//visit function that performs actions on a chunk of data
	virtual void visit(Data* data)=0;
};

/*
	class : Acceptor
	desc : This class is made to create an accept function for 
		the vistor pattern for the case where VisitorElement
		wouldn't necessarily work here easily for reason.
*/
template<typedef Data>
class Acceptor
{
	Data* data;
	public :
	//default constructor
	Acceptor(){data=NULL;}
	//sets data to d
	Acceptor(Data* d){data=d;}
	//gets data
	Data* get(){return data;}
	//sets the data
	void set(Data* d){data=d;}
	//accepts the given data using a visitor. 
	void accept(Visitor<Data>* visitor)
	{visitor->visit(data);}
};

/*
	class : VisitorElement
	desc : This class is used to implement the visitor pattern
	along with the Visitor class. It should hopefully make it 
	easier to deal with implementing objects that have this kind
	of pattern.The classes that need to use a visitor object should
	inherit from this object to since they are something that
	the vistor could visit.
*/
class VisitorElement
{
	public :
	void accept(Visitor<VisitorElement>* vistor)
	{visitor->visit(this);}
};




////////////////////////////////////////////////////////////
//this is similar to visitor pattern well it is visitor pattern
//it just doesn't use virtual at all used for dispatch tables or 
//implementing them without the bulk of virtual.
template<typename Data>
class Dispatcher
{
	public:
	void dispatch(Data& d){}
		
};

template<typename Dispatch>
class DispatchElement
{
	public:
		void accept(Dispatch& d){d.dispatch(this);}
};


#endif
